package me.ydq.core.sql;

import me.ydq.core.SqlSpec;
import me.ydq.misc.Fn;

import java.util.function.Supplier;

public interface SqlIsNull<T> {

    SqlSpec<T> isNull(Fn<T, ?> fn);

    SqlSpec<T> isNull(String column);

    default SqlSpec<T> isNull(Supplier<Boolean> condition, Fn<T, ?> fn) {
        return condition.get() ? isNull(fn) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> isNull(boolean condition, Fn<T, ?> fn) {
        return condition ? isNull(fn) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> isNull(Supplier<Boolean> condition, String rawColumn) {
        return condition.get() ? isNull(rawColumn) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> isNull(boolean condition, String rawColumn) {
        return condition ? isNull(rawColumn) : (SqlSpec<T>) this;
    }
}
